package com.itlaobing.binary;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;

@WebServlet("/enc/type")
public class EnctypeServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String method = request.getMethod();
        System.out.println( method );

        if ("GET".equalsIgnoreCase(method)){
            String query = request.getQueryString();
            System.out.println("GET => QueryString: " + query);
        }else {
            String enctype = request.getHeader("content-type");
            System.out.println( "POST => content-type : " + enctype );
            
            BufferedReader reader = request.getReader();
            String s;
            while ((s = reader.readLine()) == null){
                System.out.println(s);
            }
        }
    }
}
